define(['jquery', 'bootstrap', 'utilback', 'table', 'form', 'myfileinput','zh'], function ($, undefined, Utilback, Table, Form,myfileInput,zh) {

    var Controller = {
    	config: {
    		get_url: '/user/read/detail', // 获取用户详情
    	},
        init: function () {
//      	获取页面参数
//      	var url = window.location.href;
//      	var b = url.split("?")[1];
//			var id = b.split('&')[0];console.log(id);
//			if(id){
//				this.onPreBody();
//			}
        	
            // 初始化表格参数配置
            Table.api.init({
            	singleSelect: true,
                extend: {
                    index_url: './json/person.json', // 查询列表
                    add_url: 'driverInfoAdd.html', // 新增页面
                    edit_url: 'driverInfoAdd.html', // 修改页面
                    del_url: '/driverInfo', // 删除
                    multi_url: '/driverInfo',
                    img_url:'driverInfoImg.html',
                    guidIn_url:'driverGuidIn.html',//添加导入页面
                }
            });
            var table = $("#userTable");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                method:'get',
                showExport:true,
                columns: [
                    [
                        {field: 'state', checkbox: true, 'class':'hide'},
                        {field: 'id', title: '序号'},
                        {field: 'socialNum', title: '社保号'},
                        {field: 'workShop', title: '车间'},
                        {field: 'temgroup', title: "班组"},
                        {field: 'userName', title: "姓名"},
                        {field: 'idCard', title: "身份证号"},
                        {field: 'driverType', title: "司机类型"},
                        {field: 'licenceNum',title:'驾驶证号/准驾机型'},
                        {field: 'degreeCulture', title: "文化程度"},
                        {field: 'learnDriveNum', title: "学习司机证"},
                        {field: 'driveCard', title: "司机证"},
                        {field: 'validTime', title: "有效时间"},
                        {field: 'skillRange', title: "技能等级"},
                        {field: 'certificate', title: "高铁合格证"},
                        {field: 'phone', title: "联系电话"},
                        {field: 'carNum', title: "车号"},
                        {field: 'driverNum', title: "司机编号"},
                        {field:'picture',title:"图片",formatter : function (value,row,index) {
                            return Table.api.formatter.addtabs(value,row,index,$.fn.bootstrapTable.defaults.extend.img_url);
                        }},
                        {field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: function (value, row, index) {
                                return Table.api.formatter.operate.call(this, value, row, index, table);
                            }},
                    ]
                ],
//              onprebody:function(id){
//              	
//              }
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
           },
		
        edit: function () { // 初始化编辑页面
            // 导入的时间绑定
            Form.api.bindevent($("form[role=form]"));
            Form.api.fill($("form[role=form]"),'./json/person.json',1);
            // 导入图片
            $("#excelFile").fileinput({
                           uploadUrl: "/FileUpload/Upload",//上传的地址
                            msgPlaceholder:'请选择图片',
                            uploadAsync: true,              //异步上传
                            language: 'zh',                 //设置语言
                            showCaption: true,              //是否显示标题
                            showUpload: true,               //是否显示上传按钮
                            showRemove: true,               //是否显示移除按钮
                            showPreview : true,             //是否显示预览按钮
                            browseClass: "btn btn-primary", //按钮样式 
                            dropZoneEnabled: false,         //是否显示拖拽区域
                            allowedFileExtensions: ["xls", "xlsx","txt",'png','jpg'], //接收的文件后缀
                            maxFileCount: 10,                        //最大上传文件数限制
                            previewFileIcon: '<i class="glyphicon glyphicon-file"></i>',
                            allowedPreviewTypes: null,
                            previewFileIconSettings: {
                                'docx':'<i class="glyphicon glyphicon-file"></i>',
                                'xlsx':'<i class="fa fa-file-o"></i>',
                                'pptx': '<i class="glyphicon glyphicon-file"></i>',
                                'jpg': '<i class="glyphicon glyphicon-picture"></i>',
                                'pdf': '<i class="glyphicon glyphicon-file"></i>',
                                'zip': '<i class="fa fa-file-o"></i>',
                            },
                            uploadExtraData: {  //上传的时候，增加的附加参数
                                folder: '数据导入文件', guid: $("#AttachGUID").val()
                            }
                        })
        },
        update: function() {
            Form.api.bindevent($("form[role=form]"));
        	Util.api.ajax({
        		type: 'GET',
                url:'',
        	}, function(data) {
        		$('#edit-form').autofill(data);
        	});
        },
    };
    return Controller;
      function changeAgentContent(){
            document.getElementById("inputFileAgent").value
     = document.getElementById("inputFile").value;
    }

});